<template>
  <div v-if="tableData">
    <!-- <Search :search="search" :reset="reset">
        <template v-slot:body>
          <el-form-item label="关联单据ID" prop="production_order_id">
            <el-input v-model="query.production_order_id" name="production_order_id" clearable />
          </el-form-item>  
          <el-form-item label="页码" prop="page">
            <el-input-number v-model="query.page" :min="1"   />
          </el-form-item>  
          <el-form-item label="每页显示行数" prop="limit">
            <el-input-number v-model="query.limit" :min="1" :max="10"  /> 
          </el-form-item>  
        </template>
      </Search> -->

    <div class="table-default" v-if="tableData">
      <el-table :data="tableData" class="mt-3" v-loading="loading" border>
        <el-table-column prop="fseq" label="行号" width="80" />
        <!-- <el-table-column prop="id" label="明细ID" />
        <el-table-column prop="production_order_id" label="关联的单据ID" min-width="120"/> -->
        <el-table-column prop="fentryid" label="单据体内码" min-width="110" />
        <el-table-column prop="fmaterialid1" label="子项SKU" width="150" />
        <el-table-column prop="fmaterialname1" label="子项物料名称" width="330" />
        <el-table-column prop="fmaterialmodel1" label="规格" min-width="200" />
        <el-table-column prop="fmodel1" label="型号" min-width="170" />
        <el-table-column prop="fpositionno" label="位置号" />
        <el-table-column prop="fnumerator" label="分子">
          <template #default="scope">
            {{ Number(scope.row.fnumerator) }}
          </template>
        </el-table-column>
        <el-table-column prop="fdenominator" label="分母">
          <template #default="scope">
            {{ Number(scope.row.fdenominator) }}
          </template>
        </el-table-column>

        <el-table-column prop="funitid1_number" label="子项单位编码" width="130" />
        <el-table-column prop="funitid1_name" label="子项单位名称" width="130" />
        <el-table-column prop="ffixscrapqty" label="固定损耗" width="100">
          <template #default="scope">
            {{ Number(scope.row.ffixscrapqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fscraprate" label="变动损耗率%" min-width="120">
          <template #default="scope">
            {{ Number(scope.row.fscraprate) }}
          </template>
        </el-table-column>
        <el-table-column prop="fmustqty" label="应发数量" width="100">
          <template #default="scope">
            {{ Number(scope.row.fmustqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fpickedqty" label="已领数量" width="100">
          <template #default="scope">
            {{ Number(scope.row.fpickedqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fsolidcollarqty" label="实领数量" width="100">
          <template #default="scope">
            {{ Number(scope.row.fsolidcollarqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fnopickedqty" label="未领数量" width="100">
          <template #default="scope"> {{ Number(scope.row.fmustqty) - Number(scope.row.fpickedqty) }} </template>
        </el-table-column>
        <el-table-column prop="ftranslateqty" label="调拨数量" width="100">
          <template #default="scope">
            {{ Number(scope.row.ftranslateqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="frepickedqty" label="补领数量" width="100">
          <template #default="scope">
            {{ Number(scope.row.frepickedqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fgoodreturnqty" label="良品退料数量" min-width="130">
          <template #default="scope">
            {{ Number(scope.row.fgoodreturnqty) }}
          </template>
        </el-table-column>
        <el-table-column prop="fsupplymode" label="供料方式" min-width="120" />
        <el-table-column prop="fmemo1" label="备注" width="180" />
        <el-table-column prop="creator_id" label="创建人" />
        <el-table-column prop="created_at" label="创建时间" min-width="200" />
        <el-table-column prop="updated_at" label="更新时间" min-width="200" />
      </el-table>
      <Paginate />
    </div>
  </div>
</template>
  <script lang="ts" setup>
import { computed, nextTick, onMounted, ref } from 'vue'
import { toRaw } from '@vue/reactivity'
import Create from './create.vue'
import { useGetList } from '/admin/composables/curd/useGetList'
import { useDestroy } from '/admin/composables/curd/useDestroy'
import { useOpen } from '/admin/composables/curd/useOpen'
import { useRouter } from 'vue-router'
import { ArrowDownBold } from '@element-plus/icons-vue'
const router = useRouter()
const api = `production/order/detail?production_order_id=${props.proID}`

const { data, query, search, reset, loading } = useGetList(api)
const { destroy, deleted } = useDestroy()
const { open, close, title, visible, id } = useOpen()

const tableData = computed(() => data.value?.data)

nextTick(() => {
  console.log(tableData)
  let dataList = toRaw(tableData)
  console.log(dataList)
})

// console.log(JSON.parse(JSON.stringify(tableData.value)));

// console.log('查询请求数据', (tableData as any)?.value.fnumerator)

const props = defineProps({
  proID: Number,
})

const num = ref('100.0000')
console.log(Number(num.value))

onMounted(() => {
  search()
  deleted(reset)
})
</script>
  
  <style lang="css">
.backBtn {
  margin: 20px 10px;
}
</style>
  